package ihc.terminalbanco.gui.events;

import ihc.terminalbanco.gui.panels.AvisoPainel;
import ihc.terminalbanco.testDatas.Datas;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class KeyActionsMelhorIdade implements KeyListener {
       private JPanel menuPrincipalPanel, extratoMenuPanel, servicosMenuPanel,
                demonstrativoMenuPanel, emprestimoMenuPanel, pagamentoMenuPanel,
                saqueMenuPanel,saldoPanel, agendaPanel, informePanel,
                codigoBarrasPanel, saqueOutroValorPane, senhaAdicionalPane,
                outrosExtratosPane, maisServicosPanel, outrosPagamentosPane,
                ajudaPanel, bemVindoMenuPanel;
        AvisoPainel extratoAvisoPanel, saqueAvisoPanel, confirmarOperacaoPanel;
        JFrame frameInterface;
        Events events;
        Datas coletandoDados;

	public KeyActionsMelhorIdade (Datas coletandoDados) {
            this.coletandoDados = coletandoDados;
        }

	public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DECIMAL || e.getKeyCode() == KeyEvent.VK_DELETE) {
               events.atualizaFrameInterface(bemVindoMenuPanel);
               this.coletandoDados.incrementNumberOfCancels();
            }

            if (Events.atualPanel.equals(menuPrincipalPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(saldoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(extratoMenuPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(saqueMenuPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(servicosMenuPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.atualizaFrameInterface(pagamentoMenuPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }

            } else if (Events.atualPanel.equals(extratoMenuPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(extratoAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(extratoAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(extratoAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(outrosExtratosPane);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }

            } else if(Events.atualPanel.equals(outrosExtratosPane)){
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(extratoAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(extratoAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(extratoAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(outrosExtratosPane);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }


            }else if (Events.atualPanel.equals(saqueMenuPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(saqueAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(saqueAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(saqueAvisoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(saqueOutroValorPane);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                     events.atualizaFrameInterface(ajudaPanel);
                }
                
        } else if (Events.atualPanel.equals(saqueAvisoPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(menuPrincipalPanel);
                } 

        } else if (Events.atualPanel.equals(saqueOutroValorPane)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2){
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                }
        } else if (Events.atualPanel.equals(servicosMenuPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(emprestimoMenuPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(demonstrativoMenuPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(maisServicosPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }
        } else if (Events.atualPanel.equals(demonstrativoMenuPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }

            } else if (Events.atualPanel.equals(maisServicosPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(senhaAdicionalPane);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }
            } else if (Events.atualPanel.equals(senhaAdicionalPane)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    
                }
            } else if (Events.atualPanel.equals(emprestimoMenuPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }
            }else if (Events.atualPanel.equals(pagamentoMenuPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(codigoBarrasPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(outrosPagamentosPane);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6){
                    events.atualizaFrameInterface(ajudaPanel);
                }
            } else if (Events.atualPanel.equals(codigoBarrasPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }
            } else if (Events.atualPanel.equals(agendaPanel)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(this.informePanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD3) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD4) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD5) {
                    events.voltarFrameInterface();
                } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD6) {
                    events.atualizaFrameInterface(ajudaPanel);
                }
            } else if (Events.atualPanel.equals(saldoPanel) ||
                       Events.atualPanel.equals(senhaAdicionalPane) ||
                       Events.atualPanel.equals(saqueOutroValorPane)) {
                if (e.getKeyCode() == KeyEvent.VK_NUMPAD1 &&
                        !Events.atualPanel.equals(saldoPanel)) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                } else if (Events.atualPanel.equals(saldoPanel) ||
                        e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                }else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2) {
                    events.atualizaFrameInterface(confirmarOperacaoPanel);
                }
            } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD1) {
            } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2 
                    && !Events.atualPanel.equals(senhaAdicionalPane)
                    && !Events.atualPanel.equals(saqueOutroValorPane)
                    && !Events.atualPanel.equals(ajudaPanel)){
                events.atualizaFrameInterface(menuPrincipalPanel);
            } else if (e.getKeyCode() == KeyEvent.VK_NUMPAD2
                    && Events.atualPanel.equals(ajudaPanel)){
                events.voltarFrameInterface();
            } else if(e.getKeyCode() == KeyEvent.VK_ENTER  && Events.atualPanel.equals(bemVindoMenuPanel)){
                events.atualizaFrameInterface(menuPrincipalPanel);
            }
	}

        public void inicializaKeyAction(Events events){
        this.events = events;
        //((TerminalPane) this.atualPanel).setKeyEvents(this);
        this.menuPrincipalPanel = events.getMenuPrincipalPanel();
        this.extratoMenuPanel = events.getExtratoMenuPanel();
        this.servicosMenuPanel = events.getServicosMenuPanel();
        this.demonstrativoMenuPanel = events.getDemonstrativoMenuPanel();
        this.emprestimoMenuPanel = events.getEmprestimoMenuPanel();
        this.pagamentoMenuPanel = events.getPagamentoMenuPanel();
        this.saqueMenuPanel = events.getSaqueMenuPanel();
        this.saldoPanel = events.getSaldoPanel();
        this.agendaPanel = events.getAgendaPanel();
        this.extratoAvisoPanel = events.getExtratoAvisoPanel();
        this.saqueAvisoPanel = events.getSaqueAvisoPanel();
        this.frameInterface = events.getFrameInterface();
        this.frameInterface = events.getFrameInterface();
        this.codigoBarrasPanel = events.getCodigoBarrasPanel();
        this.saqueOutroValorPane = events.getSaqueOutroValorPane();
        this.senhaAdicionalPane = events.getSenhaAdicionalPane();
        this.outrosExtratosPane = events.getOutrosExtratosPane();
        this.maisServicosPanel = events.getMaisServicosPanel();
        this.outrosPagamentosPane = events.getOutrosPagamentosPane();
        this.confirmarOperacaoPanel = events.getConfirmarOperacao();
        this.bemVindoMenuPanel = events.getBemVindoMenuPanel();
        this.informePanel = events.getInformePanel();
        this.ajudaPanel = events.getAjudaPanel();
        }

	public void keyReleased(KeyEvent e) {
		// sem implementa��o

	}

	public void keyTyped(KeyEvent e) {
		// sem implementa��o
	}

    public JPanel getAgendaPanel() {
        return agendaPanel;
    }

    public void setAgendaPanel(JPanel agendaPanel) {
        this.agendaPanel = agendaPanel;
    }

    public JPanel getDemonstrativoMenuPanel() {
        return demonstrativoMenuPanel;
    }

    public void setDemonstrativoMenuPanel(JPanel demonstrativoMenuPanel) {
        this.demonstrativoMenuPanel = demonstrativoMenuPanel;
    }

    public JPanel getEmprestimoMenuPanel() {
        return emprestimoMenuPanel;
    }

    public void setEmprestimoMenuPanel(JPanel emprestimoMenuPanel) {
        this.emprestimoMenuPanel = emprestimoMenuPanel;
    }

    public AvisoPainel getExtratoAvisoPanel() {
        return extratoAvisoPanel;
    }

    public void setExtratoAvisoPanel(AvisoPainel extratoAvisoPanel) {
        this.extratoAvisoPanel = extratoAvisoPanel;
    }

    public JPanel getExtratoMenuPanel() {
        return extratoMenuPanel;
    }

    public void setExtratoMenuPanel(JPanel extratoMenuPanel) {
        this.extratoMenuPanel = extratoMenuPanel;
    }

    public JFrame getFrameInterface() {
        return frameInterface;
    }

    public void setFrameInterface(JFrame frameInterface) {
        this.frameInterface = frameInterface;
    }

    public JPanel getMenuPrincipalPanel() {
        return menuPrincipalPanel;
    }

    public void setMenuPrincipalPanel(JPanel menuPrincipalPanel) {
        this.menuPrincipalPanel = menuPrincipalPanel;
    }

    public JPanel getPagamentoMenuPanel() {
        return pagamentoMenuPanel;
    }

    public void setPagamentoMenuPanel(JPanel pagamentoMenuPanel) {
        this.pagamentoMenuPanel = pagamentoMenuPanel;
    }

    public JPanel getSaldoPanel() {
        return saldoPanel;
    }

    public void setSaldoPanel(JPanel saldoPanel) {
        this.saldoPanel = saldoPanel;
    }

    public AvisoPainel getSaqueAvisoPanel() {
        return saqueAvisoPanel;
    }

    public void setSaqueAvisoPanel(AvisoPainel saqueAvisoPanel) {
        this.saqueAvisoPanel = saqueAvisoPanel;
    }

    public JPanel getSaqueMenuPanel() {
        return saqueMenuPanel;
    }

    public void setSaqueMenuPanel(JPanel saqueMenuPanel) {
        this.saqueMenuPanel = saqueMenuPanel;
    }

    public JPanel getServicosMenuPanel() {
        return servicosMenuPanel;
    }

    public void setServicosMenuPanel(JPanel servicosMenuPanel) {
        this.servicosMenuPanel = servicosMenuPanel;
    }



}
